<?php

$logo = I("post.logo");

if ($logo) {
    $dir = C("uploads.upload") . $table;
    checkDirExists(C("uploads.upload") . $table);
       $new = $dir . "/" . basename($logo);
    if ($id > 0) {
        $logo_old = getSingleField($id, $table, "logo");
     
        if ($logo_old) {
            unlink($logo_old);
        }
    }
    $logo_relative_path = C("uploads.temp") . basename($logo);
    rename($logo_relative_path, $new);
//    echo $logo_relative_path."<hr>".$new;exit;
    $data['logo'] = $new;
    $unlink_files = array(
        0 => array("width" => "287", "height" => "0"),
        1 => array("width" => "366", "height" => "0"),
        2 => array("width" => "87", "height" => "87"),
        2 => array("width" => "200", "height" => "200"),
    );
    $file_path = C("uploads.upload") . $table . "/";
    foreach ($unlink_files as $v) {
        $unlink_name = $dir . "/" . $old_name . "_" . $v['width'] . "_" . $v['height'] . $type;
//         echo $unlink_name;exit;
        if (file_exists($unlink_name)) {
            unlink($unlink_name);
        }
    }
}

if ($logo == -1) {
    $data['logo'] = '';
}
?>
